home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Compiler error on long multiplication?
- Date: Tue, 06 Feb 96 15:47:49 GMT
- Organization: none
- Message-ID: <823621669snz@genesis.demon.co.uk>
- References: <4f4fr0$pea@newnews.iafrica.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4f4fr0$pea@newnews.iafrica.com>
- vizier@iafrica.com "Pieter Malan" writes:
-
- >This code was compiled with 3.1. When compiled for 80386, the
- >one onswer is wrong as indicated. For all other processors the
- >answer is correct. WHY??
- >
- >void main()
-
- In C main returns int. By declaring it as returning void here you absolve
- the compiler of all responsibility for compiling your code in any sensible
- way.
-
- >{
- >unsigned long a; //OR SIGNED
-
- Also please post to comp.lang.c code that people with C compilers can
- compile. In C comments are delimited by /* and */; // is a syntax error.
-
- >unsigned long x;
- >
- > a = 1;
- > x = (a * 100L) * 100L; // x = 13379344 WRONG!!!
- > a = 100;
- > x = a * 100L; // x = 10000
- >
- >}
-
- This code doesn't print any answer. You should post the actual code you
- used to print the answer since the problem might be in how you printed it.
- There is nothing wrong with the expressions given. Maybe Borland have
- more work to do on their 80386 code generator but that's can't be determined
- without knowing the exact program you used to generate the output.
-
- It is interesting to note that 13379344 & 0xffff is 10000
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-